package com.supsky.service2.commons;

import org.hibernate.MappingException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentityGenerator;

import java.io.Serializable;

public class IdGen extends IdentityGenerator {

    @Override
    public Serializable generate(SharedSessionContractImplementor session, Object o) throws MappingException {
        long round = Math.round(Math.random() * 100);
        if (round > 0) {
            return round;
        }
        return super.generate(session, o);
    }

}
